package com.chenyue.cm.user.service.impl;


import java.io.Serializable;

import javax.annotation.Resource;
import com.chenyue.cm.base.service.BaseServiceImpl;
import com.chenyue.cm.base.dao.LcBaseMapper;
import com.chenyue.cm.common.utils.StringUtil;
import com.chenyue.cm.utils.DateUtils;
import org.springframework.beans.factory.annotation.Qualifier;
import com.chenyue.cm.user.dao.JdGoodsStockLogMapper;
import com.chenyue.cm.user.domain.JdGoodsStockLog;
import com.chenyue.cm.user.service.JdGoodsStockLogService;
import org.springframework.stereotype.Service;


/**
*
* @author chenyue-cm
*/
@Service(value = "JdGoodsStockLogService")
public class JdGoodsStockLogServiceImpl extends BaseServiceImpl<JdGoodsStockLog>  implements JdGoodsStockLogService {

private final JdGoodsStockLogMapper jdGoodsStockLogMapper;

	public JdGoodsStockLogServiceImpl(@Qualifier("jdGoodsStockLogMapper") JdGoodsStockLogMapper jdGoodsStockLogMapper) {
		this.jdGoodsStockLogMapper = jdGoodsStockLogMapper;
	}

	@Override
	@Resource(name = "jdGoodsStockLogMapper")
	public void setBaseMapper(LcBaseMapper<JdGoodsStockLog, Serializable> baseMapper) {
		this.baseMapper = baseMapper;
	}

	@Override
	public void saveStockLog(String skuId, int logType, int originalNum, int changeNum, int resultNum) {
		JdGoodsStockLog stockLog = new JdGoodsStockLog();
		stockLog.setId(StringUtil.getUuid());
		stockLog.setSkuId(skuId);  //规格id
		stockLog.setLogType(logType);  //日志类型
		stockLog.setOriginalNum(originalNum);  //原库存数量
		stockLog.setChangeNum(changeNum);  //变更数量
		stockLog.setResultNum(resultNum);  //变动后数量
		stockLog.setCreateTime(DateUtils.getCurrentTime());
		this.save(stockLog);
	}
}
